﻿namespace Beetle
{
    using System;
    using System.Runtime.CompilerServices;

    public class DetectTimeoutHandler : Task
    {
        private ObjectArraySegment<TcpChannel> _field_a = new ObjectArraySegment<TcpChannel>(TcpUtils.Connections * 2);
        [CompilerGenerated]
        private TcpServer _field_b;

        protected override void Execute()
        {
            if ((this.Server != null) && this.Server.IsRunning)
            {
                int tickCount = Environment.TickCount;
                this.Server.GetOnlines(this._field_a);
                for (int i = 0; i < this._field_a.Count; i++)
                {
                    if ((tickCount - this._field_a.Array[i].TickCount) >= TcpUtils.TimeOutms)
                    {
                        this._field_a.Array[i].CloseStatus = "Request Timeout!";
                        this._field_a.Array[i].Dispose();
                    }
                }
            }
            else
            {
                base.Dispose();
            }
        }

        public TcpServer Server
        {
            [CompilerGenerated]
            get
            {
                return this._field_b;
            }
            [CompilerGenerated]
            internal set
            {
                this._field_b = value;
            }
        }
    }
}

